def numRollsToTarget(n: int, k: int, target: int) -> int:
    if target>n*k or target<0: return 0
    dp=[1]*k+[0]*(n*k-k)
    for i in range(n-1):
        for j in range(len(dp)-1,-1,-1):
            dp[j]=sum(dp[max(j-k,0):j])

    return dp[target-1]%(10**9+7)

print(numRollsToTarget(1,6,3))